/**
    ATClab - scriptable Air Traffic Control simulations.
    Copyright (C) 2010 openatclab@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/

#ifndef __FEEDBACK_TASK_HDR__
#define __FEEDBACK_TASK_HDR__

#include "task.h"

class QBoxLayout;
class QFrame;
class QLabel;
class QPushButton;
class QGridLayout;

namespace pact 
{
	enum FeedbackChoice
	{
		FEEDBACK_NO_CHOICE = 0,			// Experimenter-forced feedback
		FEEDBACK_PARTICIPANT_CHOICE = 1	// Participant chosen feedback
	};

	enum FeedbackType
	{
		FEEDBACK_NONE = 0,
		FEEDBACK_SELF_REFERENT = 1,
		FEEDBACK_NORMATIVE = 2,
		FEEDBACK_GENERAL = 3
	};

	class FeedbackTaskBuilder;

	struct ConditionText
	{
		std::string m_condition;
		int m_value;
		std::string m_text;
	};

	class FeedbackTask : public Task 
	{
		Q_OBJECT
		friend class FeedbackTaskBuilder;
	public:

		~FeedbackTask();

		void showEvent(QShowEvent*);

	signals:
		void sig_shown();

	private:
		FeedbackTask(FeedbackTaskBuilder*);

		void DisplayFeedback(FeedbackTaskBuilder* a_builder);

		void SetConditionalText(FeedbackTaskBuilder* a_builder);

		FeedbackTaskBuilder* m_builder;
	};

	class FeedbackTaskBuilder : public xml::DocumentView 
	{
		friend class FeedbackTask;

	public:
		FeedbackTaskBuilder();
		~FeedbackTaskBuilder();

		void SetFont(const QFont& a_font);
		void SetText(const std::string& a_text);
		void SetGlobalRef(const std::string& a_globalRef);
		void SetGoalText(const std::string&  a_text);
		void SetLink(const std::string& a_link);
		void SetFeedback();
		void SetCondition(const std::string& a_condition,
							const int a_value,
							const std::string& a_text);
		void SetType(FeedbackType a_type) { m_type = a_type; }

		FeedbackTask* build();

	private:
		QFrame*			m_widget;
		QBoxLayout*		m_textLayout;
		QBoxLayout*		m_goalTextLayout;
		QGridLayout*	m_screenLayout;
		QPushButton*	m_button;
		QFont			m_font;
		long			m_feedbackValue;
		FeedbackType	m_type;
		std::string		m_text;
		QLabel*			m_feedbackLabel;
		QLabel*		m_conditionLabel;
		std::vector<ConditionText>  m_conditionTexts;
	};
};
#endif
